#include "DGGSFeature.hpp"
#include "DGGSFeatureClass.hpp"
using namespace NNU::DGGS::Feature;
using namespace NNU::DGGS;
using namespace NNU::DGGS::Base;

DGGSFeature::DGGSFeature(DGGSFeatureClass& featureClass)
{
    this->_geometry= nullptr;
    this->_featureClass=&featureClass;
}

DGGSFeature::~DGGSFeature()
{
    if(this->_geometry!= nullptr)
        delete this->_geometry;
    this->_geometry= nullptr;
    this->_featureClass= nullptr;
}

int DGGSFeature::getLevel()
{
    return this->_featureClass->getLevel();
}

NNU::DGGS::DGGSElementType DGGSFeature::getElementType()
{
    return this->_featureClass->getElementType();
}

NNU::DGGS::DGGSGeometryType DGGSFeature::getGeomType()
{
    return this->_featureClass->getGeometryType();
}

NNU::DGGS::DGGSGridType DGGSFeature::getGridType()
{
    return this->_featureClass->getGridType();
}

bool DGGSFeature::operator==(const DGGSFeature& other)const
{
    if(this->_featureID == other._featureID&&this->_geometry[0]==other._geometry[0])
        return true;
    else
        return false;
};

bool DGGSFeature::operator!=(const DGGSFeature& other)const
{
    if(this->_featureID == other._featureID&&this->_geometry[0]==other._geometry[0])
        return false;
    else
        return true;
}

void DGGSFeature::setGeometry(DGGSGeometry *geometry)
{
    if(this->_geometry != nullptr)
        delete this->_geometry;
    this->_geometry = nullptr;
    this->_geometry = geometry->deepCopy();

}




